﻿/*
按日期排序 
Time Limit:1000MS  Memory Limit:32768K


Description:
有一些日期，日期格式为“MM/DD/YYYY”。编程将其按日期大小排列。
Sample Input:
12/31/2005
10/21/2003
02/12/2004
15/12/1999
10/22/2003
11/30/2005
Sample Output:
15/12/1999
10/21/2003
10/22/2003
02/12/2004
11/30/2005
12/31/2005
*/


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

class Date{
private:
	int year, month, day;
public:
	Date(const string& s)
	{
		sscanf(s.c_str(), "%d/%d/%d", &month, &day, &year);
	}
	bool compare(const Date& date) const
	{
		if(year==date.year)
		{
			if(month==date.month)
				return day<date.day;
			else
				return month<date.month;
		}
		return year<date.year;
	}
};

struct Comparator{
	bool operator()(const Date& date1, const Date& date2)
	{
		return date1.compare(date2);
	}
};
int compare (const string& date1, const string& date2)
{	
	int ymd1[3]={0}, ymd2[3]={0};
	
	sscanf(date1.c_str(), "%d/%d/%d", ymd1, ymd1+1, ymd1+2);
	sscanf(date2.c_str(), "%d/%d/%d", ymd2, ymd2+1, ymd2+2);

	if(ymd1[2]==ymd2[2])
	{
		if(ymd1[1]==ymd2[1])
			return ymd1[0]<ymd2[0];
		else
			return ymd1[1]<ymd2[1];
	}
	else
		return ymd1[2]<ymd2[2];

}

int main()
{

	vector<string> vdate;
	
	for (string date;cin>>date;)
	{
		vdate.push_back(date);
	}
	
	sort(vdate.begin(), vdate.end(), compare);

	copy(vdate.begin(), vdate.end(), ostream_iterator<string>(cout, "\n"));
	return 0;
}